<?php
    /**
    * các hàm webservices
    * author: ducnv
    */
    class WebService{    
        public $url;
        public $user;
        public $password;
        /**
        * hàm khởi tạo các url webservices
        *     
        */
        public function __construct(){
            $this->url = 'http://210.211.97.7:8083/VesoService.asmx?wsdl';        
            $this->user    = 'veso';    
            $this->password    = 'veso';   
        }
        /**
        * check tài khoản của 1 user
        * 
        * @param mixed $user_id
        * @return mixed
        */    
        public function requestResult($phone,$p_code,$solan){                
            try{
                $client = new soapclient('http://210.211.97.7:8083/VesoService.asmx?wsdl');   
            }catch (Exception $e) {
                echo 'Caught exception: ',  $e->getMessage(), "\n";
            }

            switch($solan){
                case 7 :
                    $sc = '8512';
                    break;
                case 20 :
                    $sc = '8612';
                    break;
                case 30 :
                    $sc = '8712';
                    break;
                default:
                    $sc = '8512';
                    break;

            }

            $result = array(
            'sc' => $sc,
            'misdn' => $phone,
            'location' => $p_code,            
            'user' => 'veso',
            'pass' => 'veso'
            );


            $rs = $client->__call("sendResult",array($result));            
            //echo $test->sendResultResult;die;        
        }

        public function requestSoi($phone,$p_code,$solan){                          
            try{
                $client = new soapclient('http://210.211.97.7:8083/VesoService.asmx?wsdl');                   
            }catch (Exception $e) {
                echo 'Caught exception: ',  $e->getMessage(), "\n";
            }                  
            $soi = array(            
            'misdn' => $phone,
            'num' => $solan,
            'location' => $p_code,            
            'user' => 'veso',
            'pass' => 'veso'
            );

            //$rs = $client->__call("sendResult",array($result));
            $rs = $client->__call("sendSoi",array($soi));            
            //return $rs->sendSOIResult;die;        
        }

    }
?>
